<template>
    <div class="book-box">
        <header>
            <div class="zuo"><img src="../../assets/向左.png" alt=""></div>     
            <input type="text" class="search" value="1991">
            <i>搜索</i>
        </header>
        <main>
            <div class="search">
                <h3>推荐搜索</h3>
                <div class="list">
                    <li  v-for="(item , index) in searchList.data" :key="index">{{ item.bookname }}</li>
                </div>
            </div>
        </main>
        
        <div class="banner">
            <ul v-for="(item,index ) in imgList.data" :key='index'>
                    <div class="xuhao"><i >{{ item.id }}</i></div>
                    
                    <div class="tupian">
                        <img :src="item.imgUrl" alt="">
                    </div>
                    <div class="book">
                        <li class="name">{{ item.name }}</li>
                        <li class="list">{{ item.list }}</li>   
                    </div>
                        
            </ul>
        </div>
    </div>
</template>

<script>
import { banner_req } from "@/modeApi/banner.js";
import { search_req } from "@/modeApi/search.js";
    export default {
        data(){
            return{
                imgList:{},
                searchList:{},
            }          
        },
        mounted(){
            this.getBanner();
            this.getSearch();
        },
        methods:{
            async getBanner(){
                const result = await banner_req({
                    method:'get',
                    url:'/home/banner',

                });
                console.log(result);
                if(result.status == 200){
                    this.imgList = result.data;
                }
                console.log(this.imgList.data);
            },

            async getSearch(){
                const result = await search_req({
                    method:'get',
                    url:'/search',

                });
                console.log(result);
                if(result.status == 200){
                    this.searchList = result.data;
                }
                console.log(this.searchList.data);
            },
        },
    };
</script>

<style lang="scss" scoped>
.book-box{
    background:  url(https://img.js.design/assets/img/62cfd4951633aec7611865fc.jpg);
}
header {
        width: 100%;
        height: 50px;
        display: flex;
        align-items: center;
        i{
            width: 50px;
            font-size: 12px;
            text-align: center;
        }
        .zuo {
            width: 50px;
            img{
                width: 30px;
                height: 30px;
                opacity: 1;
                margin-left: 10px;
            }
            
        }
        .search {
            width: 254px;
            padding-left: 40px;
            font-size: 0.4rem;
            flex: 1;
            height: 32px;
            color: #A39D8A;
            border-radius: 17.5px;
            background: url(https://p0.meituan.net/travelcube/99c29829cf1b85d5cdbc76a1bd0b7329814.png) no-repeat;
            background-position: 9px 11px;
            background-size: 14px 14px;
        }
    }
main{
    margin-top: 20px;
    .search{
        width: 90%;
        border: 1px solid #FFFAE6 ;
        margin-left: 4%;
        border-radius: 20px 20px 0 0;
        // border-radius: 20px 20px, 0px, 0px;
        list-style: none;
        background: rgba(190, 145, 97, 1);
        // width: 343px;
        height: 122px;
        padding-left: 7px;
        h3{
            color: white;
            margin-bottom: 10px;
        }
        .list{
            display: flex;
            flex-wrap: wrap;
            
            li{
                border-radius: 16px;
                background: rgba(245, 233, 213, 1);
                width: 60px;
                height: 17px;
                margin-top: 10px;
                margin-left: 10px;
                text-align: center;
                // border-radius: 5px;
                // background-color: #FFCA00;
                // line-height: 40px;
                font-size: 12px;
                font-weight: 500;
                letter-spacing: 0px;
                line-height: 17.38px;
                color: rgba(115, 115, 115, 1);
            }
        }
    }
}

.banner{
    padding-top: 20px;
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    background: rgba(252, 236, 204, 1);
    ul{       
        display: flex;
        list-style: none;
        margin: 5px 5px;
        .xuhao{
            width: 40px;
            line-height: 50px;
            color: orange;
        }
        img{
            width: 50px;
            height: 66px;
        }
        .book{
            width: 73px;
            display: flex;
            flex-direction: column;
            justify-content: space-between;
            .name{
                text-align: center;
                font-size: 14px;
                margin-top: 10px;
            }
            .list{
                text-align: center;
                margin-bottom: 10px;
                font-size: 12px;
                color: rgb(181, 179, 179);
            }
        }
    }
}
</style>